FROM golang:1.15-buster
WORKDIR /opt/build
ADD go.mod .
RUN set -ex&&export GO111MODULE=on&&export GOSUMDB=off&&export GOPROXY=https://goproxy.cn&&go mod download
ADD . .
RUN set -ex&&export GO111MODULE=on&&export GOSUMDB=off&&export GOPROXY=https://goproxy.cn&&go build -o store .

FROM errort/alpine-glibc:3.12
WORKDIR /opt/store
COPY start.sh .
COPY --from=0 /opt/build/store store
RUN set -ex&&chmod +x store&&chmod +x start.sh
ENTRYPOINT ["/opt/store/start.sh"]